#ifndef CHIPDRIVERPROFILE_C
#define CHIPDRIVERPROFILE_C
#include <p18cxxx.h>
#include "ChipDriverProfile.h"


void configureChipPeripherials() {
    // Make all of 3 digital inputs
    LATA = 0x00;
    TRISA = 0xFF;
    // Turn all analog inputs into digital inputs
    ADCON1 = 0x0F;
    // Turn off the ADC
    ADCON0bits.ADON = 0;
    // Turn off our own idea of how many analog channels to convert

    CMCON = 0x07; // Comparators as digital inputs
    // Make all of PORTB inputs
    LATB = 0x00;
    TRISB = 0xFF;
    // Make all of PORTC inputs
    LATC = 0x00;
    TRISC = 0xFF;
}

void configureInterruptionTimers() {
    //TODO Damien provided only as sample
    // Now init our registers
    // The prescaler will be at 16
    //    T2CONbits.T2CKPS1 = 1;
    //    T2CONbits.T2CKPS0 = 1;
    //    // We want the TMR2 post scaler to be a 3
    //    T2CONbits.T2OUTPS3 = 0;
    //    T2CONbits.T2OUTPS2 = 0;
    //    T2CONbits.T2OUTPS1 = 1;
    //    T2CONbits.T2OUTPS0 = 0;
    // Enable TMR0 for our RC timing operation
    //	T0CONbits.PSA = 1;		// Do NOT use the prescaler
    //	T0CONbits.T0CS = 0;		// Use internal clock
    //	T0CONbits.T08BIT = 0;	// 16 bit timer
    //	INTCONbits.TMR0IF = 0;	// Clear the interrupt flag
    //	INTCONbits.TMR0IE = 0;	// And clear the interrupt enable
    //	INTCON2bits.TMR0IP = 0;	// Low priority
    //
    //    // Enable interrupt priorities
    //    RCONbits.IPEN = 1;
    //	T2CONbits.TMR2ON = 0;
    //
    //    PIE1bits.TMR2IE = 1;
    //    IPR1bits.TMR2IP = 0;
    //
    //    INTCONbits.GIEH = 1;	// Turn high priority interrupts on
    //    INTCONbits.GIEL = 1;	// Turn low priority interrupts on
    //
    //	// Turn on the Timer2
    //	T2CONbits.TMR2ON = 1;
    //
    //	T3CONbits.TMR3ON = 0;
}